<?php
declare (strict_types=1);

namespace Plugin\Device\Model;

use Mine\MineModel;
use Plugin\Organization\Model\RdOrganizeAreaStand;

class RdDeviceBroadcast extends MineModel
{
    /**
     * The table associated with the model.
     *
     * @var string|null
     */
    protected ?string $table = 'rd_device_broadcast';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected array $fillable = [
        'id', 'code', 'name', 'server_id', 'ip', 'device_id', 'rod_id', 'status', 'volume', 'remarks', 'addr', 'created_at', 'updated_at', 'created_by', 'updated_by', 'stand_id'
    ];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected array $casts = [
        'id' => 'integer',
        'server_id' => 'integer',
        'device_id' => 'integer',
        'rod_id' => 'integer',
        'status' => 'integer',
        'volume' => 'integer',
        'stand_id' => 'integer',
        'created_by' => 'integer',
        'updated_by' => 'integer',
        'created_at' => 'datetime',
        'updated_at' => 'datetime',
        'deleted_at' => 'datetime',
    ];

    public function rod()
    {
        return $this->belongsTo(RdDeviceRod::class, 'rod_id', 'id');
    }

    public function stand()
    {
        return $this->belongsTo(RdOrganizeAreaStand::class, 'stand_id', 'id');
    }

    public function server()
    {
        return $this->belongsTo(RdDeviceBroadcastServer::class, 'server_id', 'id');
    }
}